
<!DOCTYPE html>
<HTML>
<HEAD>
	<TITLE> ZTREE DEMO - checkbox</TITLE>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">

	<link rel="stylesheet" href="http://www.treejs.cn/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<link rel="stylesheet" href="http://training-static.linesno.com/metroStyle/metroStyle.css" type="text/css">
    <link href="http://training-static.linesno.com/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

	<script type="text/javascript" src="http://www.treejs.cn/v3/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="http://www.treejs.cn/v3/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="http://www.treejs.cn/v3/js/jquery.ztree.excheck.js"></script>

    <style type="text/css">
        .tree-box{
            padding: 5px;
            width: 100%;
            margin: auto;
        }
    </style>

	<SCRIPT type="text/javascript">
		var setting = {
			async: {
				enable: true,
				url:"/manager/machine_all"
			},
			check: {
				enable: true
			},
			data: {
				simpleData: {
					enable: true , 
					idKey : "id", // id编号命名   
                    pIdKey : "applicationId", // 父id编号命名    
                    rootPId : 0 
				} , 
				key: {
					name: "machineName"
				} 
			} ,
			callback: {
				onCheck: zTreeOnCheck
			}
		};
		
		function zTreeOnCheck(event, treeId, treeNode) {
			console.log("event:" + event + " , treeId:" + treeId + " , treeNode:" + treeNode);
			
			var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
			var nodes = treeObj.getCheckedNodes(true);
			var h = "" ; 
			for(var i = 0 ; i < nodes.length ; i ++){
				h += nodes[i].id ; 
				if(i != nodes.length - 1){
					h += "|" ; 
				}
			}
			console.log("h = " + h) ; 
			$("input[name=selectNodes]").val(h) ; 
        }

		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, null);
		});
	</SCRIPT>


</HEAD>

<BODY>
<div class="tree-box">
	
	<input type="hidden" id="selectNodes" name="selectNodes" />
	
    <form class="form-signin">
		<div class="text-center mb-4">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</form>

</div>
</BODY>
</HTML>
